package com.xbdun.service.bmp;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

import com.xbdun.common.core.dbconfig.DataBaseConfig;
import com.xbdun.common.pkgenerators.RedisPkGenerator;
/**
 * 用户基本信息
 * @author zhanggt
 */
@SpringBootApplication
@PropertySource(value="classpath:/${spring.application.name}/config-${spring.config.name}-${spring.profiles.active}.properties",encoding="UTF-8")
@ComponentScan(basePackageClasses={BmpApplication.class,DataBaseConfig.class})
@EnableCaching
public class BmpApplication implements CommandLineRunner {
	public static void main(String[] args) {
		SpringApplication.run(BmpApplication.class,args);
	}
	public void run(String... args) throws Exception {
		//PkGenerator.generateLongPk(PkGenerateEnum.SYS_ORDER);
		/*List<Long> execute = stringRedisTemplate.execute(idGenroIdScript,Collections.singletonList("12313132"));
		System.out.println("============>"+JSON.toJSONString(execute));*/
	}
	/**
	* @Title: initRedisGenerator
	* @Description: RedisBeanId生成器
	* @return RedisPkGenerator    返回类型
	 */
	@Bean(initMethod="init")
	public RedisPkGenerator initRedisGenerator(){
		return new RedisPkGenerator();
	}
	
	/**
	* @Title: f
	* @Description: Redis执行lua脚本
	* @return    设定文件
	* @return DefaultRedisScript<Long>    返回类型
	
	@SuppressWarnings("unchecked")
	@Bean("idGeneroRedisLong")
	public DefaultRedisScript<List<Long>> f(){
		Resource resource = new ClassPathResource("redis-script-node1.lua");
		String fileName = resource.getFilename();  
	      System.out.println(fileName);  
		
		DefaultRedisScript<List<Long>> defaultRedisScript = new DefaultRedisScript<List<Long>>();
		defaultRedisScript.setResultType((Class<List<Long>>)(new ArrayList<Long>()).getClass());
		defaultRedisScript.setLocation(resource);
		
		return defaultRedisScript;
	}
	 */
}